package cc.lucien.controller;

import cc.lucien.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/web")
public class HelloController {

    @RequestMapping("/hello")
    public String hello(){
        System.out.println("Hello SpringMVC!");
        return "hello";
    }

    @RequestMapping(value = "/hello/*", method = RequestMethod.GET,
    params = {"name", "age=18"})
    public String hello2(){
        return "hello";
    }

    @RequestMapping("/testParams1")
    public String testParams1(Integer id, String username) {
        System.out.println("id="+id+", username="+username);
        return "hello";
    }

    @RequestMapping("/testParams2/{id}")
    public String testParams2(@PathVariable Integer id) {
        System.out.println(id);
        return "hello";
    }

    @RequestMapping("/testParams3")
    public String testParams3(User user) {
        System.out.println(user);
        return "hello";
    }

}
